/**********************************************************************************************************
** 驱动文件：	jmkt-NetCol8000.c
** 驱动类型：	jmkt
** 设备名称：	精密空调
** 设备型号：	NetCol8000
** 设备品牌：	华为
** 设备协议：	Modbus-RTU
** 驱动描述：	NetCol8000-A是针对中小型数据中心的房间级风冷智能温控产品，在运营商、ISP、政府、金融、能源、医疗及教育等行业广泛应用。
** 生成日期：	2020-04-23 20:19:04
**********************************************************************************************************/
#include "Includes.h"


/**********************************************************************************************************
* 定义设备数据点变量结构
**********************************************************************************************************/
typedef struct{
	Var SettingTemp;							//设定温度
	Var SettingHumi;							//设定湿度
	Var SystemOnOffStatus;						//系统开关状态
	Var ReturnTemp;								//回风温度
	Var ReturnHumi;								//回风湿度
	Var CoolingMode;							//制冷模式
	Var HeatingMode;							//制热模式
	Var AirSupplyMode;							//送风模式
	Var HumidificationMode;						//加湿模式
	Var DehumidificationMode;					//除湿模式
	Var AlarmStatus;							//告警总状态
	Var PowerDeviceProtection;					//功率器件保护
	Var MotorOutOfStep;							//压缩机失步
	Var FanStall;								//风机堵转
	Var DriverOutputPhaseLoss;					//驱动器输出缺相
	Var ParameteRWFailed;						//参数读写失败
	Var AbnormalSpeedOfOutdoorFan;				//室外风机转速异常
	Var OutdoorFanFailure;						//室外风机故障
	Var DC12VUnderVoltage;						//12V欠压
	Var PowerSupplyAlarm;						//电源告警
	Var PhaseLossOrUndervoltage;				//电网缺相或欠压
	Var CoolingFanAlarm;						//散热风扇告警
	Var OverLifeOperationOfFan;					//风机超年限运行
	Var DCBusAlarm;								//直流母线告警
	Var OverTempInverterPowerDevice;			//逆变功率器件过温
	Var InverterOutputOvercurrent;				//逆变输出过流
	Var SamplingZeroDriftTooLarge;				//采样零漂过大
	Var OutputGround;							//输出接地
	Var AbnormalMainsFrequency;					//电网频率异常
	Var OutputCurrentImbalance;					//输出电流不平衡
	Var AbnormalPressureSensor;					//压力传感器异常
	Var FanOverTemperature;						//风机过温
	Var OutdoorUnitHighTempAlarm;				//室外机高温告警
	Var ElectricControlBoxOverTemp;				//电控盒过温
	Var CompressorPhaseLoss;					//压缩机驱动缺相告警
	Var CompressorDriverModuleOverHeatAlarm;	//压缩机驱动模块过热告警
	Var CompressorDriveOvercurrentAlarm;		//压缩机驱动过电流告警
	Var OutdoorUnitPowerHardwareFailure;		//室外机功率硬件故障
	Var CompressorPressureAlarm;				//压缩机压力告警
	Var CompressorExhaustHighTempAlarm;			//压缩机排气高温告警
	Var OutdoorUnitMainBoardFailure;			//室外机主板故障
	Var CompressorStartFailureAlarm;			//压缩机启动失败告警
}Data_Struct;									//定义变量结构


/**********************************************************************************************************
* 设备数据点变量属性声明
**********************************************************************************************************/
const static Var_Property_Def var_attr[] = {
	{
		FLOAT,
		0,
		READONLY,
		"SettingTemp",
		"设定温度",
		"℃",
		"设定回风温度",
		0,
		0,
		"",
		"",
		0.000,
		0.000
	},
	{
		FLOAT,
		0,
		READONLY,
		"SettingHumi",
		"设定湿度",
		"%",
		"设定回风湿度",
		0,
		0,
		"",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"SystemOnOffStatus",
		"系统开关状态",
		"",
		"系统开关状态：0-关闭；1-开启",
		0,
		0,
		"系统闭关告警",
		"",
		0.000,
		0.000
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnTemp",
		"回风温度",
		"℃",
		"当前回风温度",
		0,
		0,
		"回风温度过高",
		"回风温度过低",
		0.000,
		0.000
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnHumi",
		"回风湿度",
		"%",
		"当前回风湿度",
		0,
		0,
		"回风湿度过高",
		"回风湿度过低",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CoolingMode",
		"制冷模式",
		"",
		"制冷模式:1-开启,2-关闭",
		0,
		0,
		"",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"HeatingMode",
		"制热模式",
		"",
		"制热模式:1-开启,2-关闭",
		0,
		0,
		"",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"AirSupplyMode",
		"送风模式",
		"",
		"送风模式:1-开启,2-关闭",
		0,
		0,
		"",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"HumidificationMode",
		"加湿模式",
		"",
		"加湿模式:1-开启,2-关闭",
		0,
		0,
		"",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"DehumidificationMode",
		"除湿模式",
		"",
		"除湿模式:1-开启,2-关闭",
		0,
		0,
		"",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"AlarmStatus",
		"告警总状态",
		"",
		"告警总状态:0-提示告警、1-重要告警、2-紧急告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"PowerDeviceProtection",
		"功率器件保护",
		"",
		"功率器件保护:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"MotorOutOfStep",
		"压缩机失步",
		"",
		"压缩机失步:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"FanStall",
		"风机堵转",
		"",
		"风机堵转:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"DriverOutputPhaseLoss",
		"驱动器输出缺相",
		"",
		"驱动器输出缺相:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ParameteRWFailed",
		"参数读写失败",
		"",
		"参数读写失败:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"AbnormalSpeedOfOutdoorFan",
		"室外风机转速异常",
		"",
		"室外风机转速异常:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OutdoorFanFailure",
		"室外风机故障",
		"",
		"室外风机故障:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"DC12VUnderVoltage",
		"12V欠压",
		"",
		"12V欠压:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"PowerSupplyAlarm",
		"电源告警",
		"",
		"电源告警:0-正常、1-过压告警、2-欠压告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"PhaseLossOrUndervoltage",
		"电网缺相或欠压",
		"",
		"电网缺相或欠压:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CoolingFanAlarm",
		"散热风扇告警",
		"",
		"散热风扇告警:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OverLifeOperationOfFan",
		"风机超年限运行",
		"",
		"风机超年限运行:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"DCBusAlarm",
		"直流母线告警",
		"",
		"直流母线告警:0-正常、1-欠压告警、2-过压告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OverTempInverterPowerDevice",
		"逆变功率器件过温",
		"",
		"逆变功率器件过温:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"InverterOutputOvercurrent",
		"逆变输出过流",
		"",
		"逆变输出过流:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"SamplingZeroDriftTooLarge",
		"采样零漂过大",
		"",
		"采样零漂过大:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OutputGround",
		"输出接地",
		"",
		"输出接地:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"AbnormalMainsFrequency",
		"电网频率异常",
		"",
		"电网频率异常:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OutputCurrentImbalance",
		"输出电流不平衡",
		"",
		"输出电流不平衡:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"AbnormalPressureSensor",
		"压力传感器异常",
		"",
		"压力传感器异常:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"FanOverTemperature",
		"风机过温",
		"",
		"风机过温:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OutdoorUnitHighTempAlarm",
		"室外机高温告警",
		"",
		"室外机高温告警:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ElectricControlBoxOverTemp",
		"电控盒过温",
		"",
		"电控盒过温:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CompressorPhaseLoss",
		"压缩机驱动缺相告警",
		"",
		"压缩机驱动缺相告警:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CompressorDriverModuleOverHeatAlarm",
		"压缩机驱动模块过热告警",
		"",
		"压缩机驱动模块过热告警:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CompressorDriveOvercurrentAlarm",
		"压缩机驱动过电流告警",
		"",
		"压缩机驱动过电流告警:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OutdoorUnitPowerHardwareFailure",
		"室外机功率硬件故障",
		"",
		"室外机功率硬件故障:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CompressorPressureAlarm",
		"压缩机压力告警",
		"",
		"压缩机压力告警：0-正常、1-低压告警、2-高压告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CompressorExhaustHighTempAlarm",
		"压缩机排气高温告警",
		"",
		"压缩机排气高温告警:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OutdoorUnitMainBoardFailure",
		"室外机主板故障",
		"",
		"室外机主板故障:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CompressorStartFailureAlarm",
		"压缩机启动失败告警",
		"",
		"压缩机启动失败告警:0-正常、1-告警",
		0,
		0,
		"告警",
		"",
		0.000,
		0.000
	}
};


/**********************************************************************************************************
* 函数名称： static void cmd_fun(short index, int addr, void *data, char *cmd, short *len)
* 函数说明： 生成获取传感器数据指令
* 输入参数： 指令索引，传感器地址，变量结构体指针,以及指令缓存区指针,指令长度
* 返回参数： 无
**********************************************************************************************************/
static void cmd_fun(short index, int addr, void *data, char *cmd, short *len)
{
	switch(index)
	{
		case 0:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x00;								
			cmd[3] = 0x01;
			cmd[4] = 0x00;	
			cmd[5] = 0x04;	
			*len = CRC16_Padding(cmd, 6);
			break;
		case 1:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x00;								
			cmd[3] = 0x0B;
			cmd[4] = 0x00;	
			cmd[5] = 0x02;	
			*len = CRC16_Padding(cmd, 6);
			break;		
		case 2:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x00;								
			cmd[3] = 0xAE;
			cmd[4] = 0x00;	
			cmd[5] = 0x01;	
			*len = CRC16_Padding(cmd, 6);
			break;
		case 3:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x01;								
			cmd[3] = 0x94;
			cmd[4] = 0x00;	
			cmd[5] = 0x03;	
			*len = CRC16_Padding(cmd, 6);
			break;
		case 4:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x02;								
			cmd[3] = 0x61;
			cmd[4] = 0x00;	
			cmd[5] = 0x04;	
			*len = CRC16_Padding(cmd, 6);			
			break;					
		default:
			break;
	}
}


/**********************************************************************************************************
* 函数名称： static int parse_fun(short index, int addr, void *data, char *buf, short len)
* 函数说明： 解析传感器响应的数据，并写入数据库
* 输入参数： 解析索引,传感器地址，变量结构体指针，以及响应数据缓存取指针，响应数据长度
* 返回参数： 返回解析结果，返回0成功，返回1失败
**********************************************************************************************************/
static int parse_fun(short index, int addr, void *data, char *buf, short len)
{
	union{
		short 			dat16;
      	unsigned char  	dat8[2];
    }DAT16_8;						   //数据类型转换	
	Data_Struct	*d = (Data_Struct*)data;

	if(buf!=NULL && buf[0]==addr && len>0 )
	{	
		if(CRC16_Check(buf,len))
		{
			switch(index)
			{
				case 0:
					DAT16_8.dat8[1] = buf[3];
					DAT16_8.dat8[0] = buf[4];
					d->SettingTemp.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[5];
					DAT16_8.dat8[0] = buf[6];
					d->SettingHumi.value.fnum = DAT16_8.dat16*0.1;	
					
					d->SystemOnOffStatus.value.str = (buf[10]&0x01)?"开启":"关闭";
					Set_Var_Status(&d->SystemOnOffStatus, 					  buf[10]&0x01?Normal:Alarm, NULL);						
					break;
				case 1:
					DAT16_8.dat8[1] = buf[3];
					DAT16_8.dat8[0] = buf[4];
					d->ReturnTemp.value.fnum = DAT16_8.dat16*0.1;
					DAT16_8.dat8[1] = buf[5];
					DAT16_8.dat8[0] = buf[6];
					d->ReturnHumi.value.fnum = DAT16_8.dat16*0.1;	
					break;
				case 2:
					d->CoolingMode.value.str = (buf[4]&0x01)?"开启":"关闭";
					Set_Var_Status(&d->CoolingMode, 							buf[4]&0x01?ON:OFF, NULL);
					
					d->HeatingMode.value.str = (buf[4]&0x02)?"开启":"关闭";
					Set_Var_Status(&d->HeatingMode, 							buf[4]&0x02?ON:OFF, NULL);
					
					d->AirSupplyMode.value.str = (buf[4]&0x04)?"开启":"关闭";
					Set_Var_Status(&d->AirSupplyMode, 							buf[4]&0x04?ON:OFF, NULL);
					
					d->HumidificationMode.value.str = (buf[4]&0x08)?"开启":"关闭";
					Set_Var_Status(&d->HumidificationMode, 						buf[4]&0x08?ON:OFF, NULL);
					
					d->DehumidificationMode.value.str = (buf[4]&0x10)?"开启":"关闭";
					Set_Var_Status(&d->DehumidificationMode,					buf[4]&0x10?ON:OFF, NULL);
					break;
				case 3:
					if(buf[4]&0x0F){
						if(buf[4]&0x01){
							d->AlarmStatus.value.str = "提示告警";
						}
						else if(buf[4]&0x02){
							d->AlarmStatus.value.str = "重要告警";	
						}
						else if(buf[4]&0x08){
							d->AlarmStatus.value.str = "紧急告警";	
						}
						Set_Var_Status(&d->AlarmStatus, Alarm, NULL);
					}
					else{
						d->AlarmStatus.value.str = "正常";
						Set_Var_Status(&d->AlarmStatus, Normal, NULL);						
					}

					d->PowerDeviceProtection.value.str							= buf[6]&0x01?"告警":"正常";
					Set_Var_Status(&d->PowerDeviceProtection, 					  buf[6]&0x01?Alarm:Normal, NULL);
					
					d->MotorOutOfStep.value.str									= buf[6]&0x02?"告警":"正常";
					Set_Var_Status(&d->MotorOutOfStep, 							  buf[6]&0x02?Alarm:Normal, NULL);
					
					d->FanStall.value.str										= buf[6]&0x04?"告警":"正常";
					Set_Var_Status(&d->FanStall, 								  buf[6]&0x04?Alarm:Normal, NULL);
					
					d->DriverOutputPhaseLoss.value.str							= buf[6]&0x10?"告警":"正常";
					Set_Var_Status(&d->DriverOutputPhaseLoss, 					  buf[6]&0x10?Alarm:Normal, NULL);
					
					d->ParameteRWFailed.value.str								= buf[6]&0x20?"告警":"正常";
					Set_Var_Status(&d->ParameteRWFailed, 						  buf[6]&0x20?Alarm:Normal, NULL);
					
					d->AbnormalSpeedOfOutdoorFan.value.str						=(buf[6]&0x40)||(buf[5]&0x80)?"告警":"正常";
					Set_Var_Status(&d->AbnormalSpeedOfOutdoorFan, 				 (buf[6]&0x40)||(buf[5]&0x80)?Alarm:Normal, NULL);
					
					d->OutdoorFanFailure.value.str								=(buf[6]&0x80)||(buf[5]&0x40)?"告警":"正常";
					Set_Var_Status(&d->OutdoorFanFailure, 						 (buf[6]&0x80)||(buf[5]&0x40)?Alarm:Normal, NULL);
					
					d->DC12VUnderVoltage.value.str								= buf[5]&0x01?"告警":"正常";
					Set_Var_Status(&d->DC12VUnderVoltage, 						  buf[5]&0x01?Alarm:Normal, NULL);
					
					if(buf[5]&0x02){
						d->PowerSupplyAlarm.value.str							= "过压告警";
						Set_Var_Status(&d->PowerSupplyAlarm, Alarm, NULL);						
					}
					else if(buf[5]&0x20){
						d->PowerSupplyAlarm.value.str							= "欠压告警";
						Set_Var_Status(&d->PowerSupplyAlarm, Alarm, NULL);	
					}
					else{
						d->PowerSupplyAlarm.value.str							= "正常";
						Set_Var_Status(&d->PowerSupplyAlarm, Normal, NULL);	
					}

					d->PhaseLossOrUndervoltage.value.str						= buf[5]&0x04?"告警":"正常";
					Set_Var_Status(&d->PhaseLossOrUndervoltage, 				  buf[5]&0x04?Alarm:Normal, NULL);
					
					d->CoolingFanAlarm.value.str								= buf[5]&0x08?"告警":"正常";
					Set_Var_Status(&d->CoolingFanAlarm, 						  buf[5]&0x08?Alarm:Normal, NULL);
					
					d->OverLifeOperationOfFan.value.str							= buf[5]&0x10?"告警":"正常";
					Set_Var_Status(&d->OverLifeOperationOfFan, 					  buf[5]&0x10?Alarm:Normal, NULL);

					if(buf[8]&0x01){
						d->DCBusAlarm.value.str									= "欠压告警";
						Set_Var_Status(&d->DCBusAlarm, Alarm, NULL);						
					}
					else if(buf[8]&0x02){
						d->DCBusAlarm.value.str									= "过压告警";
						Set_Var_Status(&d->DCBusAlarm, Alarm, NULL);	
					}
					else{
						d->DCBusAlarm.value.str									= "正常";
						Set_Var_Status(&d->DCBusAlarm, Normal, NULL);	
					}

					d->OverTempInverterPowerDevice.value.str					= buf[8]&0x08?"告警":"正常";
					Set_Var_Status(&d->OverTempInverterPowerDevice, 			  buf[8]&0x08?Alarm:Normal, NULL);
					
					d->InverterOutputOvercurrent.value.str						= buf[8]&0x70?"告警":"正常";
					Set_Var_Status(&d->InverterOutputOvercurrent, 				  buf[8]&0x70?Alarm:Normal, NULL);
					
					d->SamplingZeroDriftTooLarge.value.str						= buf[8]&0x80?"告警":"正常";
					Set_Var_Status(&d->SamplingZeroDriftTooLarge, 				  buf[8]&0x80?Alarm:Normal, NULL);
					
					d->OutputGround.value.str									= buf[7]&0x01?"告警":"正常";
					Set_Var_Status(&d->OutputGround, 							  buf[7]&0x01?Alarm:Normal, NULL);
					
					d->AbnormalMainsFrequency.value.str							= buf[7]&0x02?"告警":"正常";
					Set_Var_Status(&d->AbnormalMainsFrequency, 					  buf[7]&0x02?Alarm:Normal, NULL);	
					
					d->OutputCurrentImbalance.value.str							= buf[7]&0x04?"告警":"正常";
					Set_Var_Status(&d->OutputCurrentImbalance, 					  buf[7]&0x04?Alarm:Normal, NULL);
					
					d->AbnormalPressureSensor.value.str							= buf[7]&0x08?"告警":"正常";
					Set_Var_Status(&d->AbnormalPressureSensor, 					  buf[7]&0x08?Alarm:Normal, NULL);	
					
					d->FanOverTemperature.value.str								= buf[7]&0x10?"告警":"正常";
					Set_Var_Status(&d->FanOverTemperature, 						  buf[7]&0x10?Alarm:Normal, NULL);
					
					d->OutdoorUnitHighTempAlarm.value.str						= buf[7]&0x20?"告警":"正常";
					Set_Var_Status(&d->OutdoorUnitHighTempAlarm, 				  buf[7]&0x20?Alarm:Normal, NULL);
					
					d->ElectricControlBoxOverTemp.value.str						= buf[7]&0x40?"告警":"正常";
					Set_Var_Status(&d->ElectricControlBoxOverTemp, 				  buf[7]&0x40?Alarm:Normal, NULL);
					break;						
				case 4:
					d->CompressorPhaseLoss.value.str							= buf[4]&0x38?"告警":"正常";
					Set_Var_Status(&d->CompressorPhaseLoss, 					  buf[4]&0x38?Alarm:Normal, NULL);
					
					d->CompressorDriverModuleOverHeatAlarm.value.str			= buf[6]&0x02?"告警":"正常";
					Set_Var_Status(&d->CompressorDriverModuleOverHeatAlarm, 	  buf[6]&0x02?Alarm:Normal, NULL);
					
					d->CompressorDriveOvercurrentAlarm.value.str				= buf[6]&0x20?"告警":"正常";
					Set_Var_Status(&d->CompressorDriveOvercurrentAlarm, 		  buf[6]&0x20?Alarm:Normal, NULL);
					
					d->OutdoorUnitPowerHardwareFailure.value.str				= buf[5]&0x01?"告警":"正常";
					Set_Var_Status(&d->OutdoorUnitPowerHardwareFailure, 		  buf[5]&0x01?Alarm:Normal, NULL);

					if(buf[8]&0x04){
						d->CompressorPressureAlarm.value.str					= "低压告警";
						Set_Var_Status(&d->CompressorPressureAlarm, Alarm, NULL);						
					}
					else if(buf[7]&0x08){
						d->CompressorPressureAlarm.value.str					= "高压告警";
						Set_Var_Status(&d->CompressorPressureAlarm, Alarm, NULL);	
					}
					else{
						d->CompressorPressureAlarm.value.str					= "正常";
						Set_Var_Status(&d->CompressorPressureAlarm, Normal, NULL);	
					}

					d->CompressorExhaustHighTempAlarm.value.str					= buf[7]&0x02?"告警":"正常";
					Set_Var_Status(&d->CompressorExhaustHighTempAlarm, 			  buf[7]&0x02?Alarm:Normal, NULL);
					
					d->OutdoorUnitMainBoardFailure.value.str					= buf[10]&0x04?"告警":"正常";
					Set_Var_Status(&d->OutdoorUnitMainBoardFailure, 			  buf[10]&0x04?Alarm:Normal, NULL);
					
					d->CompressorStartFailureAlarm.value.str					= buf[9]&0x40?"告警":"正常";
					Set_Var_Status(&d->CompressorStartFailureAlarm, 			  buf[9]&0x40?Alarm:Normal, NULL);					
					break;
				default:
					break;
			}
			return 0;
		}
	}
	return 1;
}


/**********************************************************************************************************
* 函数名称： void jmkt_NetCol8000_Registration(void)
* 函数说明： 精密空调驱动注册
* 输入参数： 无
* 返回参数： 无
**********************************************************************************************************/
void jmkt_NetCol8000_Registration(void)
{
	DeviceRegWithResTimeout(
		"jmkt",													//设备类型
		"精密空调",												//设备名称（导航栏默认显示名称）
		"NetCol8000",											//设备型号
		"NetCol8000-A是针对中小型数据中心的房间级风冷智能温控产品，在运营商、ISP、政府、金融、能源、医疗及教育等行业广泛应用。",//驱动描述
		var_attr,												//变量属性声明
		sizeof(Data_Struct),									//变量结构体空间大小
		cmd_fun,												//发送指令生成函数
		parse_fun,												//数据解析函数
		500														//设备响应超时时间
	);

#if 0 || VirtualFrameEN
	#define	CMD1	"\x01\x03\x00\x01\x00\x04\x15\xC9"
	#define	RSP1	"\x01\x03\x08\x00\xE6\x01\xF4\x00\x08\x00\x01\xE2\x1F"
	#define	CMD2	"\x01\x03\x00\x0B\x00\x02\xB5\xC9"
	#define	RSP2	"\x01\x03\x04\x00\xDF\x02\x21\x0A\xB1"
	#define	CMD3	"\x01\x03\x00\xAE\x00\x01\xE5\xEB"
	#define	RSP3	"\x01\x03\x02\x00\x54\xB9\xBB"		
	#define	CMD4	"\x01\x03\x01\x94\x00\x03\x45\xDB"
	#define	RSP4	"\x01\x03\x06\x00\x00\x00\x00\x00\x00\x21\x75"		
	#define	CMD5	"\x01\x03\x02\x61\x00\x04\x14\x6F"
	#define	RSP5	"\x01\x03\x08\x00\x00\x00\x00\x00\x00\x00\x00\x95\xD7"		

	VirtualFrameRegistration(CMD1, sizeof(CMD1)-1, RSP1, sizeof(RSP1)-1);
	VirtualFrameRegistration(CMD2, sizeof(CMD2)-1, RSP2, sizeof(RSP2)-1);
	VirtualFrameRegistration(CMD3, sizeof(CMD3)-1, RSP3, sizeof(RSP3)-1);
	VirtualFrameRegistration(CMD4, sizeof(CMD4)-1, RSP4, sizeof(RSP4)-1);
	VirtualFrameRegistration(CMD5, sizeof(CMD5)-1, RSP5, sizeof(RSP5)-1);
#endif		
}

